package com.TEAM6.controller;

import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.TEAM6.beans.BooksBean;
import com.TEAM6.dao.MemberDAO;
import com.TEAM6.dao.SearchDAO;


public class SearchAction implements Action{
	public SearchAction(){}
	public Forward execute(HttpServletRequest request, HttpServletResponse response) throws Exception{
		
		String word = request.getParameter("searchtxt");
		System.out.print(word);
		Forward forward = new Forward();
		SearchDAO dao = new SearchDAO();
		
		ArrayList<BooksBean>list = new ArrayList<BooksBean>(); //선언만 되어있고 할당을 위해 new를 한다
		list = dao.searchBooks(word);
		request.setAttribute("searchlist",list);
		
		
		
		forward.setRedirect(false);
		forward.setPagePath("./main.jsp?page=search");
		
		return forward;
	}
	protected String makeHTML(String title, ArrayList<BooksBean> list, int num){
		StringBuffer sb = new StringBuffer();
		
		sb.append("<div onMouseOver='rollover("+ num +")'>" + title + list.size() + "권</div><br />");	
		return sb.toString();
	}
	
	
}
